<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>

    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
<!--    <script src="/static/js/framework-ui.js"></script>-->
<!--    <script src="/static/js/framework-clientdata.js"></script>-->

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>


    <!--    配置select多选相关-->
<!--    <script src="/static/layui/dist/xm-select.js"></script>-->


        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
    {/if}


    <script src="/static/js/jquery-2.1.1.js"></script>
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main.css"/>
    <script type="text/javascript" src='//webapi.amap.com/maps?v=2.0&key=1b5095aca8acff10518bf883f334b2ad&plugin=AMap.ToolBar'></script>
    <script src="//webapi.amap.com/ui/1.1/main.js?v=1.1.1"></script>

</head>
<body>
<style>
    html, body{background-color:#FFF!important;}
    .modal-body{background-color:#fff;padding:15px}
    .page-header{margin-top:15px!important;}
    .geographic input{width:100px!important;float: left;margin-right:15px;}
</style>

<div class="modal-body">


    <div class="page-header">
        <h3>添加分类</h3>
    </div>

    <form class="form-horizontal layui-form">

        <div class="form-group">
            <label class="col-sm-1 control-label">*分类名称:</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="name" placeholder="分类名称" >
            </div>
        </div>

        <div class="form-group js_photos">
            <label class="col-sm-1 control-label">分类图片:</label>
            <div class="col-sm-4">
                <div class="input-group ">
                    <input type="file" name="" class="do_upload" data-val="idCard_handheld"  style="display: none">
                    <input type="text" class="form-control idCard_handheld"  disabled="" value="">
                    <input type="hidden" class="form-control idCard_handheld" name="thumb" value="" >
                    <span class="group-span-filestyle input-group-btn" tabindex="0">
                            <label class="btn btn-default id_photos" data-original-title="" title="">
                                <span class="glyphicon glyphicon-folder-open"></span>
                                上传
                            </label>
                        </span>
                    </span>
                </div>
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-1 control-label">状态:</label>
            <div class="col-sm-4">
                <select name="status" >
                    {volist name="enable_status" id="vo"}
                    <option value="{$key}">{$vo}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label">排序:</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="sort" placeholder="排序" >
                <p>数值越大越靠前</p>
            </div>
        </div>


    </form>
</div>
<div class="add_button">

    <div class="form-group">
        <label  class="col-sm-1 control-label"></label>
        <div class="col-sm-8">
            <a type="button" class="layui-btn layui-btn-primary" href="{:URL('admin/News/classify')}" >取消</a>
            <button type="button" class="layui-btn" id="newsave" >保存</button>
        </div>
    </div>
</div>


<script>
    $(".id_photos").click(function () {
        $(this).parent().parent().find(".do_upload").click();
    });

    $('.js_photos').on('change','.do_upload',function(){
        var content = $(this).attr("data-val");
        var formData = new FormData();
        var name = $($(this)).val();
        var files = $($(this))[0].files[0];
        formData.append("file", files);
        formData.append("name", name);
        //另外加的参数
        formData.append("act", "PostImg");

        $.ajax({
            url: "{:URL('common/upload/ad_upload')}",
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            dataType: 'json',
            success:function (res) {
                $("."+content).val(res.path);
                //$("."+content).find("img").attr("src",res.path);
            }
            ,error:function (res) {
                alert('错误');
            }
        });
    })


    var newModal = new yii.modal();


    layui.use(['form','layedit','tree','util'], function() {
        var form = layui.form
            , layer = layui.layer;
        var layedit = layui.layedit;
        var  tree = layui.tree;
        var util = layui.util;


        $("#newsave").click(function () {
            var data = $("form").serializeArray();
            $.ajax({
                type:'post',
                url:"{:URL('admin/News/doClassify')}",
                data:data,
                dataType:'JSON',
                success:function (res) {
                    if(res.code!=0){
                        layer.alert(res.msg);
                    }else{
                        window.location.href = "{:URL('admin/News/classify')}";
                    }
                },
                error:function (res) {
                    
                }
            });

        })



        layui.form.render('select');
        form.render();


    });
</script>

</body>
</html>